package com.baseweb.webadmin.weixin.pay;

import java.math.BigDecimal;

import com.baseweb.webadmin.core.util.ToolHelper;
import com.baseweb.webadmin.weixin.utils.Constant;

/**
 * 微信支付需要的订单数据信息
 * @author wcc
 *
 */
public class OrderData {
	public double  actualTotalPay = 0;//元为单位，页面订单传入
	public String orderNum;//订单号,页面订单传入 
	public String  totalFee;//传给微信的金额 分 将 actualTotalPay转为分
	/**
	 * 商品描述  此处暂时固定为 "日有喜商家商品"
	 */
	public String body="日有喜商家商品";
	
	/**
	 * 提交用户的ip 使用：request.getRemoteAddr();
	 * 获取即可
	 */
	public String remoteAddr;
    /**
     * 接收微信支付成功异步通知回调地址
     */
	public String notifyUrl =Constant.NOTIFY_URL;
	
	public void setActualTotalPay(double actualTotalPay) {
		this.actualTotalPay = actualTotalPay;
	}
	
	public double getActualTotalPay() {
		if(ToolHelper.isEmpty(actualTotalPay)){
			actualTotalPay = 0;
		}
		return actualTotalPay;
	}

	public String getOrderNum() {
		return orderNum;
	}
	public void setOrderNum(String orderNum) {
		this.orderNum = orderNum;
	}
	
	public String getTotalFee() {
		BigDecimal totalFeeL =new BigDecimal(getActualTotalPay()*100) ;
	    if(ToolHelper.isEmpty(String.valueOf(totalFeeL))){
	    	totalFee = "0";
	    }else{
	    	totalFee = String.valueOf(totalFeeL);
	    }
		return totalFee;
	}
	
	public String getBody() {
		if(ToolHelper.isEmpty(body)){
			body = "日有喜商家商品";
		}
		return body;
	}
	
	public String getRemoteAddr() {
		return remoteAddr;
	}

	public void setRemoteAddr(String remoteAddr) {
		this.remoteAddr = remoteAddr;
	}
	
	public String getNotifyUrl() {
		if(ToolHelper.isEmpty(notifyUrl)){
			notifyUrl = Constant.NOTIFY_URL;
		}
		return notifyUrl;
	}
    
	
	public static void main(String[] args) {
		OrderData orderData = new OrderData();
		orderData.setActualTotalPay(102343.04);
		System.out.println(orderData.getTotalFee());
		
	}
	


}
